<?php

require_once 'ActionFramework/start.php';
require_once 'views/all.cls.php';

require_once 'actions/_user_settings.cls.php';

/**
 * Save the criteria and return to the edit criteria view.
 */
class SaveProfileAction extends _UserSettingsAction {
	
	public function __construct() {
		parent::__construct();
		$this->add_profile_inputs();
	}
	
	public function trigger($request) {
		// In the request, the action inputs are present, which are exactly the User attributes.
		$data = $this->extract_profile_inputs($request);
		$user = $this->update_user($data);
		
		$view = new EditProfileView($user);
		$view->add_message("Profile and preferences saved");
		return $view;
	}
}

?>